Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use random seed #971

Merged
merged 6 commits into from
Dec 24, 2024
Merged

Use random seed #971

merged 6 commits into from
Dec 24, 2024

Conversation

kfarr
Copy link
Collaborator

@kfarr kfarr commented Dec 19, 2024

No description provided.

@kfarr
Copy link
Collaborator Author

kfarr commented Dec 19, 2024

issue: on first load, some random clones do not adhere to seed, but subsequent loads do.

causes: i thought it might be race conditions that the seed hadn't been set before the clones started generated on first load, so I attempted to fix that but didn't see improvement: c500b4b

potential workaround: perhaps I can set seed value when instantiating the component from managed-street, although in a perfect world that wouldn't be necessary

screenshots:

load 1 (instantiated from streetmix -> managed street add layer button):
image

load 2 (loaded from cloud json)
image

load 3, 4, etc. (identical to load2)
image

@kfarr
Copy link
Collaborator Author

kfarr commented Dec 20, 2024

also: pedestrian placement doesn't respect seed yet

@vincentfretin
Copy link
Collaborator

The update function was called two times when creating the scene initially (you could see two floats with the console.log, not sure why) and only once when opening the scene. Just recreate the rng (that's just a function, that cheap) every time you're about to create the entities fixed the issue. I also reversed your logic, just checking things in update. Returning in init is a bit confusing because aframe will still call the update anyway.

@kfarr kfarr requested a review from rahulkgupta December 22, 2024 05:01
@kfarr
Copy link
Collaborator Author

kfarr commented Dec 22, 2024

@vincentfretin works great!

@kfarr kfarr merged commit 4cde5ab into main Dec 24, 2024
1 check passed
@kfarr kfarr deleted the use-random-seed branch December 24, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create/use seed for randomization of generated clones
2 participants